import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Login',
      component: () => import('../views/Login'),
    },
    {
      path: '/home',
      name: 'home',
      redirect: '/salesSlip',
      component: () => import('../views/Home'),
      children:[
        { path: '/salesSlip', name: 'salesSlip', component: () => import('../pages/salesSlip'),},
        { path: '/AddGood', name: 'AddGood', component: () => import('../components/AddGood'),},
        { path: '/AddSalesOrder', name: 'AddSalesOrder', component: () => import('../components/AddSalesOrder'),},
        { path: '/DetailSalesOrder', name: 'DetailSalesOrder', component: () => import('../components/DetailSalesOrder'),},
        { path: '/AuditSalesOrder', name: 'AuditSalesOrder', component: () => import('../components/AuditSalesOrder'),},
        { path: '/returnOrder', name: 'returnOrder', component: () => import('../pages/returnOrder'),},
        { path: '/DetailSalesReturnOrder', name: 'DetailSalesReturnOrder', component: () => import('../components/DetailSalesReturnOrder'),},
        { path: '/AuditReturnOrder', name: 'AuditReturnOrder', component: () => import('../components/AuditReturnOrder'),},
        { path: '/AddSalesReturnOrder', name: 'AddSalesReturnOrder', component: () => import('../components/AddSalesReturnOrder'),},
        { path: '/DetailPurchaseOrder', name: 'DetailPurchaseOrder', component: () => import('../components/DetailPurchaseOrder'),},
        { path: '/AuditPurchaseOrder', name: 'AuditPurchaseOrder', component: () => import('../components/AuditPurchaseOrder'),},
        { path: '/purchaseOrder', name: 'purchaseOrder', component: () => import('../pages/purchaseOrder'),},
        { path: '/AddPurchaseOrder', name: 'AddPurchaseOrder', component: () => import('../components/AddPurchaseOrder'),},
        { path: '/DetailPurchaseReturnOrder', name: 'DetailPurchaseReturnOrder', component: () => import('../components/DetailPurchaseReturnOrder'),},
        { path: '/AuditPurchaseReturnOrder', name: 'AuditPurchaseReturnOrder', component: () => import('../components/AuditPurchaseReturnOrder'),},
        { path: '/purchaseReturn', name: 'purchaseReturn', component: () => import('../pages/purchaseReturn'),},
        { path: '/AddPurchaseReturnOrder', name: 'AddPurchaseReturnOrder', component: () => import('../components/AddPurchaseReturnOrder'),},
        { path: '/inventoryQuery', name: 'inventoryQuery', component: () => import('../pages/inventoryQuery'),},
        { path: '/inventoryFlow', name: 'inventoryFlow', component: () => import('../pages/inventoryFlow'),},
        { path: '/inventoryCount', name: 'inventoryCount', component: () => import('../pages/inventoryCount'),},
        { path: '/inventoryTransfer', name: 'inventoryTransfer', component: () => import('../pages/inventoryTransfer'),},
        { path: '/outboundManagement', name: 'outboundManagement', component: () => import('../pages/outboundManagement'),},
        { path: '/warehousingManagement', name: 'warehousingManagement', component: () => import('../pages/warehousingManagement'),},
        { path: '/receipt', name: 'receipt', component: () => import('../pages/receipt'),},
        { path: '/paymentOrder', name: 'paymentOrder', component: () => import('../pages/paymentOrder'),},
        { path: '/DetailpaymentOrder', name: 'DetailpaymentOrder', component: () => import('../pages/DetailpaymentOrder'),},
        { path: '/settlementMethod', name: 'settlementMethod', component: () => import('../pages/settlementMethod'),},
        { path: '/commodity', name: 'commodity', component: () => import('../pages/commodity'),},
        { path: '/category', name: 'category', component: () => import('../pages/category'),},
        { path: '/attributes', name: 'attributes', component: () => import('../pages/attributes'),},
        { path: '/unitMeasurement', name: 'unitMeasurement', component: () => import('../pages/unitMeasurement'),},
        { path: '/allCustomers', name: 'allCustomers', component: () => import('../pages/allCustomers'),},
        { path: '/customerIndustry', name: 'customerIndustry', component: () => import('../pages/customerIndustry'),},
        { path: '/customerGrade', name: 'customerGrade', component: () => import('../pages/customerGrade'),},
        { path: '/supplier', name: 'supplier', component: () => import('../pages/supplier'),},
        { path: '/supplierClassification', name: 'supplierClassification', component: () => import('../pages/supplierClassification'),},
        { path: '/warehouse', name: 'warehouse', component: () => import('../pages/warehouse'),},
        { path: '/logisticsChannels', name: 'logisticsChannels', component: () => import('../pages/logisticsChannels'),},
        { path: '/roles', name: 'roles', component: () => import('../pages/roles'),},
        { path: '/staff', name: 'staff', component: () => import('../pages/staff'),},
        { path: '/OrderSalesSummary', name: 'OrderSalesSummary', component: () => import('../pages/OrderSalesSummary'),},
        { path: '/SalesPerformanceRanking', name: 'SalesPerformanceRanking', component: () => import('../pages/SalesPerformanceRanking'),},
        { path: '/OrderPurchaseSummary', name: 'OrderPurchaseSummary', component: () => import('../pages/OrderPurchaseSummary'),},
        { path: '/ProductInventoryWarning', name: 'ProductInventoryWarning', component: () => import('../pages/ProductInventoryWarning'),},
        { path: '/InventoryBalanceGoods', name: 'InventoryBalanceGoods', component: () => import('../pages/InventoryBalanceGoods'),},
        { path: '/SalesOverview', name: 'SalesOverview', component: () => import('../pages/SalesOverview'),},
        { path: '/ProcurementOverview', name: 'ProcurementOverview', component: () => import('../pages/ProcurementOverview'),},
        { path: '/AddInventoryCount', name: 'AddInventoryCount', component: () => import('../components/AddInventoryCount'),},
        { path: '/AddTransfer', name: 'AddTransfer', component: () => import('../components/AddTransfer'),},
        { path: '/AddCollectionDocument', name: 'AddCollectionDocument', component: () => import('../components/AddCollectionDocument'),},
        { path: '/DetailCollectionDocument', name: 'DetailCollectionDocument', component: () => import('../components/DetailCollectionDocument'),},
        { path: '/AddPaymentOrder', name: 'AddPaymentOrder', component: () => import('../components/AddPaymentOrder'),},
        { path: '/AddAttribute', name: 'AddAttribute', component: () => import('../components/AddAttribute'),},
        { path: '/EditAttribute', name: 'EditAttribute', component: () => import('../components/EditAttribute'),},
        { path: '/NewCustomers', name: 'NewCustomers', component: () => import('../components/NewCustomers'),},
        { path: '/EditCustomers', name: 'EditCustomers', component: () => import('../components/EditCustomers'),},
        { path: '/DetailCustomers', name: 'DetailCustomers', component: () => import('../components/DetailCustomers'),},
        { path: '/AddNewSuppliers', name: 'AddNewSuppliers', component: () => import('../components/AddNewSuppliers'),},
        { path: '/EditNewSuppliers', name: 'EditNewSuppliers', component: () => import('../components/EditNewSuppliers'),},
        { path: '/DetailNewSuppliers', name: 'DetailNewSuppliers', component: () => import('../components/DetailNewSuppliers'),},
        { path: '/NewChannels', name: 'NewChannels', component: () => import('../components/NewChannels'),},
        { path: '/EditChannels', name: 'EditChannels', component: () => import('../components/EditChannels'),},
      ]
    },
    {
      path: '/echartsPage',
      name: 'echartsPage',
      component: () => import('../components/echartsPage'),
    }
  ]

})
// 导航守卫
// 使用 router.beforeEach 注册一个全局前置守卫，判断用户是否登陆
// router.beforeEach((to, from, next) => {
//   if (to.path === '/') {
//     next()
//   } else {
//     const token = window.sessionStorage.getItem('token')
//     if (!token) {
//       next('/')
//     } else {
//       next()
//     }
//   }
// })

export default router
